#include "Mymap.h"
#include "Myset.h"


namespace Hash{
    void TestMySet()
    {
        Hash::set<int> s;
        s.insert(100);
        s.insert(200);
        s.insert(3);
        s.erase(200);
        for(auto &it:s)
        {
            cout<<it<<" ";
        }
        cout<<endl;
        Hash::set<int>::iterator it = s.begin();
    }
    void TestMyMap()
    {
        Hash::map<string, int> m;
        string arr[] = { "苹果", "西瓜", "苹果", "西瓜", "苹果", "苹果", "西瓜","苹果", "香蕉", "苹果", "香蕉" };
        for(const auto& str:arr)
        {
            m[str]++;
        }
        // m.erase("苹果");
        for(auto& ch:m)
        {
            cout<<ch.first<<"::"<<ch.second<<endl;
        }
    }
    void compare()
{
    srand(time(NULL));
    size_t testNum = 100000;//一千万个数据
    unordered_set<int> s1;
    set<int> s2;
    vector<int> v;
    for (int i = 0; i < testNum; i++)
    {
        // v.push_back(rand()%testNum);
        // v.push_back(i);//插入有序数据
        v.push_back(rand()%30000);//大量重复数据
    }
    size_t begin1 = clock();
	for (auto e : v)
	{
		s2.insert(e);
	}
	size_t end1 = clock();
	cout << "set insert:" << end1 - begin1 << endl;

    size_t begin2 = clock();
	for (auto e : v)
	{
		s1.insert(e);
	}
	size_t end2 = clock();
	cout << "unordered_set insert:" << end2 - begin2 << endl;

    size_t begin3 = clock();
	for (auto e : v)
	{
		s2.find(e);
	}
	size_t end3 = clock();
	cout << "set find:" << end3 - begin3 << endl;

	size_t begin4 = clock();
	for (auto e : v)
	{
		s1.find(e);
	}
	size_t end4 = clock();
	cout << "unordered_set find:" << end4 - begin4 << endl << endl;

    size_t begin5 = clock();
	for (auto e : v)
	{
		s2.erase(e);
	}
	size_t end5 = clock();
	cout << "set erase:" << end5 - begin5 << endl;

	size_t begin6 = clock();
	for (auto e : v)
	{
		s1.erase(e);
	}
	size_t end6 = clock();
	cout << "unordered_set erase:" << end6 - begin6 << endl << endl;
    return ;
}
};


// int main()
// {
//     Hash::TestMySet();
//     return 0;
// }